package service.impl;

import dao.RaceDao;
import dao.TeamDao;
import dao.impl.RaceDaoImpl;
import dao.impl.TeamDaoImpl;
import model.JoinTeamMsg2;
import model.Team;
import service.TeamService;

import java.util.List;

/**
 * @author CY
 * @date 2022/12/17 15:45
 **/
public class TeamServiceImpl implements TeamService {

    TeamDao dao = new TeamDaoImpl();

    @Override
    public int teamAdd(Team team) {
        return dao.insert(team);
    }

    @Override
    public int teamDelete(int tid) {
        return dao.delete(tid);
    }

    @Override
    public int teamquit(int uid, int tid) {
        return dao.teamQuite(uid, tid);
    }

    @Override
    public int teamIsFull(int tid) {
        return dao.pageCount(tid);
    }

    @Override
    public List<Team> findTeamListByRace(int rid, int pageIndex, int pageSize) {
        return dao.findTeamListByRace(rid, pageIndex, pageSize);
    }

    @Override
    public int teamListByRaceCount(int rid) {
        return dao.teamListByRaceCount(rid);
    }

    @Override
    public int getTeamUserCount(int tid) {
        return dao.getTeamUserCount(tid);
    }

    @Override
    public int teamUserAdd(int uid, int tid) {
        return dao.teamUserAdd(uid,tid);
    }
    @Override
    public List<Team> teamByRaceAndName(int rid, String tname, int pageIndex, int pageSize) {
        return dao.teamByRaceAndName(rid,tname,pageIndex,pageSize);
    }

    @Override
    public int teamByRaceAndNameCount(int rid, String tname) {
        return dao.teamByRaceAndNameCount(rid,tname);
    }

    @Override
    public boolean teamByIdAndRace(int lid, int rid) {
        return dao.teamByIdAndRace(lid, rid) == 1;
    }



    @Override
    public int countTeamByUser(int uid) {
        return dao.teamCountByUser(uid);
    }

    @Override
    public List<Team> getTeamByUser(int uid, int pageIndex, int pageSize) {
        return dao.teamListByUser(uid,pageIndex,pageSize);
    }
}

